import java.util.Scanner;
import java.util.Stack;

class Person{
    static {
        System.out.println("This is static initialization block");
    }
    private String name=null;
    private boolean gender=false;
    private int age=0;
    private int id;
    private static int num=0;

    public Person(String name, boolean gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        id=num;
        num++;
    }

    public Person() {
        System.out.println("This is initialization block, id is "+num);
        System.out.println("This is constructor");
        id=num;
        num++;
        System.out.println(name+","+age+","+gender+","+id);
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Person [" +
                "name=" + name  +
                ", age=" + age +
                ", gender=" + gender +
                ", id=" + id +
                ']';
    }
    public static int getNum(){
        return num;
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int time=sc.nextInt();
        Stack stack=new Stack();
        for (int i=0;i<time;i++){
            String name=sc.next();
            int age=Integer.valueOf(sc.next());
            boolean gender=Boolean.valueOf(sc.next());
            Person p=new Person(name,gender,age);
            System.out.println("This is initialization block, id is "+i);
            stack.push(p);
        }
        for (int i=0;i<Person.getNum();i++){
            Person person=(Person) stack.peek();
            System.out.println(person);
            stack.pop();
        }
        new Person();

    }
}
